<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改帖子')" />
	<th:block th:include="include :: select2-css" />
	<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-post-edit" th:object="${post}">
            <input id="id" name="id" th:field="*{id}"  type="hidden">
			<h4 class="form-header h4">基本信息</h4>
			<div class="form-group">
				<label class="col-sm-2 control-label">话题名称：</label>
				<div class="col-sm-3">
					<input th:value="${topicName}" class="form-control" type="text" readonly>
				</div>

				<label class="col-sm-2 control-label">用户名称：</label>
				<div class="col-sm-3">
					<input  th:value="${nickName}" class="form-control" type="text" readonly>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">审核状态：</label>
				<div class="col-sm-3">
					<!--<input id="verifyState" name="verifyState" th:field="*{verifyState}" class="form-control" type="text">-->
					<select id="verifyState" name="verifyState" class="form-control m-b" th:field="*{verifyState}">
						<option value=0>待审核</option>
						<option value=1>发布</option>
						<option value=2>隐藏</option>
					</select>
				</div>

				<label class="col-sm-2 control-label">帖子类型：</label>
				<div class="col-sm-3">
					<select id="postType" name="postType" class="form-control m-b" th:field="*{postType}">
						<option value=1>参与话题</option>
						<option value=2>不参与话题</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">公开级别：</label>
				<div class="col-sm-3">
					<select id="openLevel" name="openLevel" class="form-control m-b" th:field="*{openLevel}">
						<option value=1>仅自己可见</option>
						<option value=2>关注可见</option>
						<option value=3>所有人可见</option>
					</select>
				</div>

				<label class="col-sm-2 control-label">是否被举报：</label>
				<div class="col-sm-3">
					<select id="isComplain" name="isComplain" class="form-control m-b" th:field="*{isComplain}">
						<option value=1>是</option>
						<option value=2>否</option>
					</select>
				</div>
			</div>
			<h4 class="form-header h4">详细信息</h4>
			<div class="form-group">
				<label class="col-sm-2 control-label">帖子ID：</label>
				<div class="col-sm-3">
					<input id="id" name="id" th:field="*{id}" class="form-control" type="text" readonly>
				</div>

				<!--<label class="col-sm-2 control-label">分享数：</label>-->
				<!--<div class="col-sm-3">-->
					<!--<input id="fenxiangNum" name="fenxiangNum" th:field="*{fenxiangNum}" class="form-control" type="number">-->
				<!--</div>-->


			</div>


			<div class="form-group">
				<label class="col-sm-2 control-label">点赞量：</label>
				<div class="col-sm-3">
					<input id="likeNum" name="likeNum" th:field="*{likeNum}" class="form-control" type="number">
				</div>

				<label class="col-sm-2 control-label">浏览量：</label>
				<div class="col-sm-3">
					<input id="glanceNum" name="glanceNum" th:field="*{glanceNum}" class="form-control" type="number">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">评论量：</label>
				<div class="col-sm-3">
					<input id="commentsNum" name="commentsNum" th:field="*{commentsNum}" class="form-control" type="number">
				</div>

				<label class="col-sm-2 control-label">帖子等级：</label>
				<div class="col-sm-3">
					<input id="postLevel" name="postLevel" th:field="*{postLevel}" class="form-control" type="number">
				</div>
			</div>


			<div class="form-group">
				<label class="col-sm-2 control-label">发帖地址：</label>
				<div class="col-sm-8">
					<input id="postAddress" name="postAddress" th:field="*{postAddress}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">经度：</label>
				<div class="col-sm-3">
					<input id="addressLong" name="addressLong" th:field="*{addressLong}" class="form-control" type="text" readonly>
				</div>

				<label class="col-sm-2 control-label">纬度：</label>
				<div class="col-sm-3">
					<input id="addressLati" name="addressLati" th:field="*{addressLati}" class="form-control" type="text" readonly>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">帖子内容：</label>
				<div class="col-sm-8">
					<textarea id="postContent" name="postContent" th:field="*{postContent}" class="form-control" type="text"></textarea>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">帖子图片：</label>
				<div class="col-sm-8">
					<input id="postImg" name="postImg" th:field="*{postImg}" class="form-control" type="hidden">
					<!--<img id="postSrc" width="200px" height="200px"/>-->
				</div>
			</div>

			<div class="form-group" id="test" style="margin-left: 200px">
				<!--<label class="col-sm-2 control-label">帖子图片：</label>-->
				<!--<ul id="test" class=""></ul>-->
			</div>

			<!--<div class="form-group">	-->
				<!--<label class="col-sm-3 control-label">有效值：</label>-->
				<!--<div class="col-sm-8">-->
					<!--<input id="valid" name="valid" th:field="*{valid}" class="form-control" type="text">-->
				<!--</div>-->
			<!--</div>-->
			<div class="form-group">
				<label class="col-sm-2 control-label">建立日期：</label>
				<div class="col-sm-3">
					<input th:value="${#dates.format(post.createDate, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" type="text" readonly>
				</div>


			<!--th:value="${#dates.format(post.modifyDate, 'yyyy-MM-dd HH:mm:ss')}"-->

				<label class="col-sm-2 control-label">修改日期：</label>
				<div class="col-sm-3">
					<input th:value="${#dates.format(post.modifyDate, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" type="text" readonly>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
	<th:block th:include="include :: select2-js" />
	<th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
		var prefix = ctx + "post/post";
		$("#form-post-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});

		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/edit", $('#form-post-edit').serialize());
	        }
	    }

		var img = document.getElementById('postSrc');
		var fileinput = document.getElementById('postImg');
		if (fileinput.value != '') {
			var imgs=fileinput.value;
			var result= new Array();
			result=imgs.split(",");

			for (var i = 0; i <result.length ; i++) {
				var ls = result[i];
				html = '<div>'+ '<a class="col-sm-4">'+
						'<img style="width: 200px; height: 200px;" class="control-label" id="img'+i+'"  src="'+ls+'" />'+ '</a>'+
						'</div>';
				$('#test').append(html);
			}
			// var trueImg=result[0];
			// img.src = trueImg;
		}
	</script>
</body>
</html>
